import config from "./config/index.js";
import store from './store/index.js';
import router from './router/index.js'
import crypto from "./utils/crypto/index.js";
import storage from "./utils/storage/index.js";
import authorApi from "./api/author/index.js";
import categoryApi from "./api/category/index.js";
import menuApi from "./api/menu/index.js";
import postApi from "./api/post/index.js";
import siteApi from "./api/site/index.js";
import tagApi from "./api/tag/index.js";
import talkApi from "./api/talk/index.js";

/* 深色模式下添加粒子效果 */
import {dark} from "./assets/canvas/dark.js";

const {loadModule} = window['vue3-sfc-loader'];
const app = await Vue.createApp(Vue.defineAsyncComponent(() => loadModule('/src/App.vue', options)));

app.use(Vuex);
app.use(ElementPlus);
app.use(store);
app.use(router);

app.config.globalProperties.$config = config;
app.config.globalProperties.$CONFIG = config;
app.config.globalProperties.$crypto = crypto;
app.config.globalProperties.$CRYPTO = crypto;
app.config.globalProperties.$storage = storage;
app.config.globalProperties.$STORAGE = storage;

await authorApi.getAuthorInfo.get().then(async response => {
    await store.commit("SET_AUTHOR_INFO", response);
});
await siteApi.getSiteInfo.get().then(async response => {
    await store.commit("SET_SITE_INFO", response);
});
await siteApi.getSiteConfig.get().then(async response => {
    await store.commit("SET_SITE_CONFIG", response);
});
await siteApi.getSiteCount.get().then(async response => {
    await store.commit("SET_SITE_COUNT", response);
});
await siteApi.getConsoleRecordList.get().then(async response => {
    await store.commit("SET_CONSOLE_RECORD_LIST", response);
});
await tagApi.getConsoleTagList.get().then(async response => {
    await store.commit("SET_CONSOLE_TAG_LIST", response);
});
await talkApi.getConsoleTalkList.get().then(async response => {
    await store.commit("SET_CONSOLE_TALK_LIST", response);
});
await menuApi.getAsideMenuList.get().then(async response => {
    await store.commit("SET_ASIDE_MENU_LIST", response);
});
await menuApi.getNavigationMenuList.get().then(async response => {
    await store.commit("SET_NAVIGATION_MENU_LIST", response);
});
await menuApi.getIconMenuList.get().then(async response => {
    await store.commit("SET_ICON_MENU_LIST", response);
});
await menuApi.getNormalMenuList.get().then(async response => {
    await store.commit("SET_NORMAL_MENU_LIST", response);
});
await menuApi.getFriendMenuList.get().then(async response => {
    await store.commit("SET_FRIEND_MENU_LIST", response);
});
await categoryApi.getAsideCategoryList.get().then(async response => {
    await store.commit("SET_ASIDE_CATEGORY_LIST", response);
});
await postApi.getAsidePostList.get().then(async response => {
    await store.commit("SET_ASIDE_POST_LIST", response);
});
await siteApi.getAsideMessageList.get().then(async response => {
    await store.commit("SET_ASIDE_MESSAGE_LIST", response);
});
await siteApi.getIndexSayList.get().then(async response => {
    await store.commit("SET_INDEX_SAY_LIST", response);
});
await siteApi.getIndexBanner.get().then(async response => {
    await store.commit("SET_INDEX_BANNER", response);
});
await categoryApi.getIndexCategoryList.get().then(async response => {
    await store.commit("SET_INDEX_CATEGORY_LIST", response);
});
await postApi.getIndexPostList.get().then(async response => {
    await store.commit("SET_INDEX_POST_LIST", response);
});
await postApi.getSignPostList.get().then(async response => {
    await store.commit("SET_INDEX_SIGN_POST_LIST", response);
});

// 挂载 app
app.mount('#app');

/* 深色模式下添加粒子效果 */
dark();